package com.by.jdbc;

import java.util.HashMap;
import java.util.Map;

/**
 * <p><p/>
 *
 * @author boyin
 * @ClassName ByJdbcFactory
 * @Description jdbc仓库
 * @date 2024/12/24 6:40
 */
public class ByJdbcFactory {
    private final static Map<String, ByJdbcUtil> jdbcUtilhMap = new HashMap<>();

    private ByJdbcFactory() {
    }

    public static ByJdbcFactory getInstance() {
        return new ByJdbcFactory();
    }

    public ByJdbcUtil getJdbcUtil(String type) {
        if (jdbcUtilhMap.containsKey(type)){
            return jdbcUtilhMap.get(type);
        }
        if ("H2".equals(type)) {
            ByJdbcUtil byJdbcUtil = new ByH2Util(type);
            jdbcUtilhMap.put(type,byJdbcUtil);
            return byJdbcUtil;
        }
       throw new RuntimeException("jdbc type error !");
    }

}
